Private Function pvtUseCollection(Optional CollectionParm As Variant, Optional Verbose As Variant) As Variant
Set pvtUseCollection = _
ObjectManager. _
pvtWrapperUseCollection( _
CollectionParm:=CollectionParm, _
pvtCollection:=pvtCollection, _
Verbose:=Verbose, _
WrapperName:="Data")
End Function
Public Function Rebind( _
Optional Collection As Variant, _
Optional DataControl As Variant) As Variant
' Rebinds the Wrapper to a Collection or DataControl
' after having changed the assignment of either.
' For example, in the following scenario, the
' VBOFDataWrapper must be rebound because
' the VBOFCollection has been significantly altered:
'
' Dim pvtAddresses as VBOFCollection
' Dim pvtPerson as Person
' Dim MyDataWrapper as VBOFDataWrapper
' Set MyDataWrapper = _
' ObjectManager.NewVBOFDataWrapper ( _
' Collection:=pvtAddresses, _
' DataControl:=MyDataControl)
'
' the following line alters the state of the data
' in-effect at the time of the above binding
' Set pvtAddresses = pvtPerson.Addresses
' rebind the Wrapper
' MyDataWrapper.Rebind _
' Collection:=pvtAddresses
' bullet-proofing
If Not IsMissing(Collection) Then
If TypeName(Collection) <> _
"VBOFCollection" _
Then
pvtErrorMessage TypeName(Me) & " cannot process the '.Rebind' method because the 'Collection:=' parameter is not a VBOFCollection."
Rebind = False
Exit Function
End If
End If
If Not IsMissing(DataControl) Then
If InStr(pvtDataControlSupportedTypeNames, TypeName(pvtDataControl)) = 0 Then
pvtErrorMessage TypeName(Me) & " cannot process the '.Rebind' method because the 'DataControl:=' parameter is not a Visual Basic DataControl control. Please use a VBOF Wrapper for the " & TypeName(DataControl) & " control (or request the development of one.)"
Rebind = False
Exit Function
End If
End If
If Not pvtIsFullyInitialized( _
Collection:=Collection, _
DataControl:=DataControl, _
Verbose:=False) _
Then
Rebind = False
Exit Function
End If
pvtRefreshDataControl
Rebind = True
End Function
Public Property Get RecordSet() As RecordSet
' Returns a DataControl-ready RecordSet object
' which pertains to the collection of objects
' instantiated and contained within this
' VBOFCollection
' bullet-proofing
If Not pvtIsFullyInitialized _
(Verbose:=True) _
Then
Set RecordSet = Nothing
Exit Property
End If
Set RecordSet = _
pvtCollection.RecordSet
End Property
Public Property Get AbsolutePosition() As Long
' Pass-thru to pvtRecordSetMoveToRecordNumber
On Local Error Resume Next
' bullet-proofing
If Not pvtIsFullyInitialized _
(Verbose:=True) _
Then
AbsolutePosition = -1
Exit Property
End If
AbsolutePosition = _
pvtDataControl. _
RecordSet.AbsolutePosition
End Property
Public Property Let AbsolutePosition(RecordNumber As Long)
' Pass-thru to pvtRecordSetMoveToRecordNumber
On Local Error Resume Next
' bullet-proofing
If Not pvtIsFullyInitialized _
(Verbose:=True) _
Then
Exit Property
End If
pvtDataControl. _
RecordSet.AbsolutePosition = _
RecordNumber
End Property
Public Property Get EOF() As Boolean
' Returns a boolean, based on whether or not the
' underlying RecordSet is positioned at EOF
' bullet-proofing
If Not pvtIsFullyInitialized _
(Verbose:=True) _
Then
EOF = False
Exit Property
End If
EOF = _
pvtCollection. _
pvtRecordSetEOF
End Property
Public Function FindFirst( _
Optional SearchCriteria As Variant) As Variant
' Searches the underlying RecordSet for the first
' record meeting the specified criteria
' and returns the object for that row
' bullet-proofing
If Not pvtIsFullyInitialized _
(Verbose:=True) _
Then
Set FindFirst = Nothing
Exit Function
End If
Set FindFirst = _
pvtCollection. _
pvtRecordSetFindFirst _
(SearchCriteria:=SearchCriteria)
End Function
Public Function FindLast( _
Optional SearchCriteria As Variant) As Variant
' Searches the underlying RecordSet for the last
' record meeting the specified criteria
' and returns the object for that row
' bullet-proofing
If Not pvtIsFullyInitialized _
(Verbose:=True) _
Then
Set FindLast = Nothing
Exit Function
End If
Set FindLast = _
pvtCollection. _
pvtRecordSetFindLast _
(SearchCriteria:=SearchCriteria)
End Function
Public Function FindPrevious( _
Optional SearchCriteria As Variant) As Variant
' Searches the underlying RecordSet for the previous
' record meeting the specified criteria
' and returns the object for that row
' bullet-proofing
If Not pvtIsFullyInitialized _
(Verbose:=True) _
Then
Set FindPrevious = Nothing
Exit Function
End If
Set FindPrevious = _
pvtCollection. _
pvtRecordSetFindPrevious _
(SearchCriteria:=SearchCriteria)
End Function
Public Function FindNext( _
Optional SearchCriteria As Variant) As Variant
' Searches the underlying RecordSet for the next
' record meeting the specified criteria
' and returns the object for that row
' bullet-proofing
If Not pvtIsFullyInitialized _
(Verbose:=True) _
Then
Set FindNext = Nothing
Exit Function
End If
Set FindNext = _
pvtCollection. _
pvtRecordSetFindNext _
(SearchCriteria:=SearchCriteria)
End Function
Public Function MoveFirst() As Variant
' Moves the underlying RecordSet to the first record
' and returns the object for that row
' bullet-proofing
If Not pvtIsFullyInitialized _
(Verbose:=True) _
Then
Set MoveFirst = Nothing
Exit Function
End If
Set MoveFirst = _
pvtCollection. _
pvtRecordSetMoveFirst
End Function
Public Function MoveLast() As Variant
' Moves the underlying RecordSet to the Last record
' and returns the object for that row
' bullet-proofing
If Not pvtIsFullyInitialized _
(Verbose:=True) _
Then
Set MoveLast = Nothing
Exit Function
End If
Set MoveLast = _
pvtCollection. _
pvtRecordSetMoveLast
End Function
Public Function MoveToRecordNumber( _
Optional RecordNumber As Variant) As Variant
' Moves the underlying RecordSet to the specified
' record (by number) and returns the object for
' that row
' bullet-proofing
If Not pvtIsFullyInitialized _
(Verbose:=True) _
Then
Set MoveToRecordNumber = Nothing
Exit Function
End If
Set MoveToRecordNumber = _
pvtCollection. _
pvtRecordSetMoveToRecordNumber _
(RecordNumber:=RecordNumber)
End Function
Public Property Get RecordCount() As Long
' Returns the RecordCount property of the
' underlying RecordSet
' bullet-proofing
If Not pvtIsFullyInitialized _
(Verbose:=True) _
Then
RecordCount = -1
Exit Property
End If
RecordCount = _
pvtCollection. _
pvtRecordSetRecordCount()
End Property
Public Function Refresh( _
Optional DisplayOnly As Variant) As RecordSet
' Refresh the DataControl
' Pass thru to pvtRefreshRecordSet()
' bullet-proofing
If Not pvtIsFullyInitialized _
(Verbose:=True) _
Then
Set Refresh = Nothing
Exit Function
End If
pvtRefreshDataControl
If Not IsMissing(DisplayOnly) Then
If DisplayOnly Then
Set Refresh = _
pvtCollection.RecordSet
Else
Set Refresh = _
pvtCollection.pvtRecordSetRefresh
End If
Else
Set Refresh = _
pvtCollection.pvtRecordSetRefresh
End If
End Function
Public Function Sort( _
Optional SortField As Variant, _
Optional SortOrder As Variant) As Boolean
' Sorts the objects in the underlying
' VBOFCollection according to the field
' referenced in SortField:= and the sort
' order referenced in SortOrder:=
' For additional information, see the VBOF User's
' Guide
' Programming example:
' MyWrapper.Sort _
' SortField:="FirstName", _
' SortOrder:="ASC"
Sort = _
ObjectManager.pvtWrapperSort( _
Wrapper:=Me, _
SortField:=SortField, _
SortOrder:=SortOrder)
End Function
Public Function Unbind() As Boolean
Set pvtCollection = Nothing
Set pvtDataControl = Nothing
Set pvtVBOFObjectManager = Nothing
End Function
Public Property Get BOF() As Boolean
' Returns a boolean, based on whether or not the
' underlying RecordSet is positioned at BOF
' bullet-proofing
If Not pvtIsFullyInitialized _
(Verbose:=True) _
Then
BOF = False
Exit Property
End If
BOF = _
pvtCollection. _
pvtRecordSetBOF
End Property
Public Function Validate(Action As Integer, Save As Integer, Optional Sample As Variant, Optional Parent As Variant) As Variant
' NOT CURRENTLY SUPPORTED
' Manages the Data1_Validate event procedure for
' the bound Data control
'
' Programming example:
' Private Sub Data1_Validate(Action As Integer, Save As Integer)
' pvtPersonsDataWrapper. _
' Validate _
' Action:=Action, _
' Save:=Save
Exit Function
Dim tempActionCode As Long
On Local Error Resume Next
' make sure the Action is one that is handled
If Action = vbDataActionUpdate Then
If pvtPreviousDataControlActionCode = vbDataActionAddNew Then
tempActionCode = vbDataActionAddNew
Else
tempActionCode = vbDataActionUpdate
End If
ElseIf Action = vbDataActionDelete Then
Action = vbDataActionDelete
Else
pvtPreviousDataControlActionCode = Action
Set Validate = Nothing
Exit Function
End If
' bullet-proofing
If Not pvtIsFullyInitialized _
(Verbose:=True) _
Then
Set FindPrevious = Nothing
Exit Function
End If
If IsMissing(Action) Then
pvtErrorMessage TypeName(Me) & " cannot process the '.Validate' method because the 'Action:=' parameter is missing."
Set Validate = Nothing
Exit Function
End If
If IsMissing(Save) Then
pvtErrorMessage TypeName(Me) & " cannot process the '.Validate' method because the 'Save:=' parameter is missing."